package com.carltechnology.mahjonggamecaculation.dao;

import android.content.ContentValues;
import android.database.Cursor;

import com.carltechnology.mahjonggamecaculation.mode.IBaseData;

import java.util.List;

/**
 * Created by WZTCM on 2016/6/28.
 */
public interface IMahjongDataDao {
    /**
     * open database to do some operating
     */
    void openDataBase();

    /**
     * close the database.
     */
    void closeDataBase();

    /**
     * judge if the database is open.
     *
     * @return true if it's open.Or false.
     */
    boolean isOpen();

    /**
     * query the database.
     *
     * @param dbName    the database's name.
     * @param dataOrder how the data is ordered.
     * @return an cursor with data
     */
    Cursor query(String dbName, String dataOrder);

    /**
     * query the database with the data's id to get specified data.
     *
     * @param dbName    the database's name.
     * @param dataOrder how the data is ordered.
     * @return an cursor with data
     */
    Cursor queryById(String dbName, String dataOrder, final int id);

    /**
     * clear the database.Here we use transaction to avoid the exception to do harm to our app.
     *
     * @return true if it's finished well.Or the operation is wrong.
     */
    boolean clearRuntimeTable();

    /**
     * Updata the table we set.
     *
     * @param tableName the table name
     * @param iBaseData the new data
     * @param values    the value to update database
     * @return true if successed.
     */
    boolean updateTable(String tableName, IBaseData iBaseData, ContentValues values);

    /**
     * delete the mode we set
     *
     * @param tableName table name
     * @param iBaseData the delete mode
     * @return result
     */
    boolean deleteData(String tableName, IBaseData iBaseData);

    /**
     * insert mode into our table.
     *
     * @param tableName the table name
     * @param values    the values
     * @return the result
     */
    boolean insertData(String tableName, ContentValues values);

    /**
     * insert list mode into our table
     *
     * @param tableName the table name
     * @param values    the values
     * @return the result
     */
    boolean insertListDatas(String tableName, List<ContentValues> values);


}
